import { InjectionKey } from '@vue/runtime-core'
import { createStore, Store, useStore as baseUseStore } from 'vuex'
import { IAdmin } from './modules/admin/types'
import adminStore from './modules/admin'
import { ICommon } from './modules/common/types'
import commonStore from './modules/common'

interface IRootState{
  adminStore:IAdmin
  commonStore:ICommon
}

export const key: InjectionKey<Store<IRootState>> = Symbol('store')

export const store: Store<IRootState> = createStore({
  modules: {
    adminStore,
    commonStore
  }
})

export function useStore () {
  return baseUseStore(key)
}
